using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace LL3D
{
   
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;

        ///Aqui estao as 4 telas do jogo------------------------------
        public static int telaAtual;
        public static IntroScreen telaInicial;       //telaAtual = 1
        public static GameScreen telaJogo;         //telaAtual = 2
        public static ControlScheme telaControles;   //telaAtual = 3
        public static GameOver telaEnd;              //telaAtual = 4
        //-----------------------------------------------------------

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            //Tamanho da janela------------------------------
            graphics.PreferredBackBufferWidth = 800;
            graphics.PreferredBackBufferHeight = 600;
            //-----------------------------------------------
        }
       
        protected override void Initialize()
        {
            //Inicializando as telas do jogo
            telaInicial = new IntroScreen(Content);
            telaControles = new ControlScheme(Content);
            telaJogo = new GameScreen(Content, GraphicsDevice);
            telaEnd = new GameOver(Content);
            telaAtual = 1;
            base.Initialize();
        }

        
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            
        }


        protected override void Update(GameTime gameTime)
        {
            switch (telaAtual)
            {
                case 1:
                    telaInicial.Update();  // Atualizando a tela de intro
                    break;
                case 2:
                    telaJogo.Update(); // Atualizando a tela de jogo
                    break;
                case 3:
                    telaControles.Update();  // Atualizando a tela de controles
                    break;
                case 4:
                    telaEnd.Update();
                    break;
                case 5:
                    this.Exit();            //Fechando o jogo
                    break;
            }

            base.Update(gameTime);
        }

       
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            switch (telaAtual)
            {
                //Desenhando a tela inicial
                case 1:
                    telaInicial.Draw(spriteBatch);
                    break;
                //Desenhando a tela jogo
                case 2:
                    telaJogo.Draw(spriteBatch);
                    break;
                //Desenhando a tela de controles
                case 3:
                    telaControles.Draw(spriteBatch);  
                    break;
                //Desenhando tela game over
                case 4:
                    telaEnd.Draw(spriteBatch);
                    break;

            }
            
            base.Draw(gameTime);
        }
    }
}
